import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {

    public static String sha1(String input) {
        if (input == null) {
            return null;
        }

        try {
            MessageDigest sha1Digest = MessageDigest.getInstance("SHA-1");
            byte[] hashBytes = sha1Digest.digest(input.getBytes());

            // 转换为十六进制字符串
            StringBuilder hexString = new StringBuilder();
            for (byte b : hashBytes) {
                String hex = Integer.toHexString(0xFF & b);
                if (hex.length() == 1) {
                    hexString.append('0');
                }
                hexString.append(hex);
            }

            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("SHA-1 algorithm not found", e);
        }
    }

    public static void main(String[] args) {
        String input = "iscbupt";
        String hash = sha1(input);
        System.out.println("Library SHA-1 hash of \"" + input + "\":");
        System.out.println(hash);
    }
}